import { IPSAppWF } from '../../app/wf/ipsapp-wf';
import { IPSAppWFUIAction } from '../../app/wf/ipsapp-wfuiaction';
import { IPSAppWFVer } from '../../app/wf/ipsapp-wfver';
import { PSDEUIActionImpl } from './psdeuiaction-impl';
import { IPSWorkflow } from '../../wf/ipsworkflow';

export class WFPSDEUIActionImpl extends PSDEUIActionImpl implements IPSAppWFUIAction {
  protected psappwf: IPSAppWF | null = null;

  getPSAppWF(): IPSAppWF | null {
    if (this.psappwf != null) return this.psappwf;
    const value = this.M.getPSAppWF;
    if (value == null) {
      return null;
    }
    this.psappwf = this.getPSModel4('app.wf.IPSAppWF', value, 'getPSAppWF') as IPSAppWF;
    return this.psappwf;
  }

  get psAppWF(): IPSAppWF | null {
    return this.getPSAppWF();
  }

  getPSAppWFMust(): IPSAppWF {
    const value = this.getPSAppWF();
    if (value == null) {
      throw new Error('未指定应用工作流');
    }
    return value;
  }

  protected psappwfver: IPSAppWFVer | null = null;

  getPSAppWFVer(): IPSAppWFVer | null {
    if (this.psappwfver != null) return this.psappwfver;
    const value = this.M.getPSAppWFVer;
    if (value == null) {
      return null;
    }
    this.psappwfver = this.getPSModel4('app.wf.IPSAppWFVer', value, 'getPSAppWFVer') as IPSAppWFVer;
    return this.psappwfver;
  }

  get psAppWFVer(): IPSAppWFVer | null {
    return this.getPSAppWFVer();
  }

  getPSAppWFVerMust(): IPSAppWFVer {
    const value = this.getPSAppWFVer();
    if (value == null) {
      throw new Error('未指定应用工作流版本');
    }
    return value;
  }

  protected psworkflow: IPSWorkflow | null = null;

  getPSWorkflow(): IPSWorkflow | null {
    if (this.psworkflow != null) return this.psworkflow;
    const value = this.M.getPSWorkflow;
    if (value == null) {
      return null;
    }
    this.psworkflow = this.getPSModel4('wf.IPSWorkflow', value, 'getPSWorkflow') as IPSWorkflow;
    return this.psworkflow;
  }

  get psWorkflow(): IPSWorkflow | null {
    return this.getPSWorkflow();
  }

  getPSWorkflowMust(): IPSWorkflow {
    const value = this.getPSWorkflow();
    if (value == null) {
      throw new Error('未指定系统工作流');
    }
    return value;
  }

  get cls(): string {
    return 'WFPSDEUIActionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.wf.IPSAppWFUIAction' || cls == 'wf.IPSWorkflowObject' || cls == 'wf.uiaction.IPSWFUIAction') return true;
    return super.instanceof(cls);
  }
}
